<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/res/css/admin_main.css"/>
    <script src="${pageContext.request.contextPath}/res/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/res/js/bootstrap.min.js"></script>
    <script>
        function getChildPage(element) {
            // 获取订单ID
            var orderId = $(element).closest('tr').find('.order_id').text();
            // 跳转到订单详情页面
            window.location.href = "${pageContext.request.contextPath}/admin/orderDetails?orderId=" + orderId;
        }
    </script>
    <style>
        /* 分页样式 */
        .pagination {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .pagination ul {
            list-style-type: none;
            padding: 0;
            margin: 0;
            display: flex;
        }

        .pagination li {
            margin: 0 5px;
        }

        .pagination a {
            display: inline-block;
            padding: 8px 16px;
            text-decoration: none;
            color: #333;
            background-color: #f4f4f4;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .pagination a:hover {
            background-color: #ddd;
        }

        .pagination .active {
            background-color: #007bff;
            color: white;
            border-color: #007bff;
        }

    </style>
    <script>
        function getPage(pageNumber) {
            window.location.href = "${pageContext.request.contextPath}/admin/order?index=" + pageNumber;
        }

        //jiade代码
        function getChildPage(element) {
            // 获取订单ID
            var orderId = $(element).closest('tr').find('.order_id').text();
            // 跳转到订单详情页面
            window.location.href = "${pageContext.request.contextPath}/admin/orderDetails?orderId=" + orderId;
        }
    </script>
</head>
<body>
<div class="frm_div text_info">
    <div class="frm_group">
        <label class="frm_label" id="lbl_productOrder_code" for="input_productOrder_code">订单号</label>
        <input class="frm_input" id="input_productOrder_code" type="text" maxlength="20"/>
        <label class="frm_label" id="lbl_productOrder_post" for="input_productOrder_post">邮政编码</label>
        <input class="frm_input" id="input_productOrder_post" type="text" maxlength="6"/>
        <input class="frm_btn" id="btn_productOrder_submit" type="button" value="查询"/>
        <input class="frm_btn frm_clear" id="btn_clear" type="button" value="重置"/>
    </div>

    <div class="frm_group">
        <label class="frm_label" id="lbl_productOrder_status" for="checkbox_productOrder_status_waitPay">订单状态</label>
        <input class="frm_radio radio_productOrder_status" id="checkbox_productOrder_status_waitPay" name="checkbox_productOrder_status" type="checkbox" value="0" checked>
        <label class="frm_label" id="lbl_productOrder_status_waitPay" for="checkbox_productOrder_status_waitPay" title="等待买家付款">待付款</label>
        <input class="frm_radio radio_productOrder_status" id="checkbox_productOrder_status_waitDelivery" name="checkbox_productOrder_status" type="checkbox" value="1" checked>
        <label class="frm_label" id="lbl_productOrder_status_waitDelivery" for="checkbox_productOrder_status_waitDelivery" title="买家已付款，等待卖家发货">待发货</label>
        <input class="frm_radio radio_productOrder_status" id="checkbox_productOrder_status_waitConfirm" name="checkbox_productOrder_status" type="checkbox" value="2" checked>
        <label class="frm_label" id="lbl_productOrder_status_waitConfirm" for="checkbox_productOrder_status_waitConfirm" title="卖家已发货，等待买家确认">待确认</label>
        <input class="frm_radio radio_productOrder_status" id="checkbox_productOrder_status_success" name="checkbox_productOrder_status" type="checkbox" value="3" checked>
        <label class="frm_label" id="lbl_productOrder_status_success" for="checkbox_productOrder_status_success" title="交易成功">交易成功</label>
        <input class="frm_radio radio_productOrder_status" id="checkbox_productOrder_status_close" name="checkbox_productOrder_status" type="checkbox" value="4" checked>
        <label class="frm_label" id="lbl_productOrder_status_close" for="checkbox_productOrder_status_close" title="交易关闭">交易关闭</label>
        <span class="frm_error_msg" id="text_productOrder_msg"></span>
    </div>
    <div class="frm_group_last">
        <input class="frm_btn frm_refresh" id="btn_productOrder_refresh" type="button" value="刷新订单列表"/>
    </div>
</div>
<div class="data_count_div text_info">
    <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2522" width="16"
         height="16">
        <path d="M401.976676 735.74897c-88.721671 0-172.124196-34.635845-234.843656-97.526197-62.724577-62.86784-97.271394-146.453537-97.271394-235.358379s34.546817-172.490539 97.276511-235.361449c62.715367-62.887282 146.117892-97.522104 234.838539-97.522104 88.719624 0 172.135452 34.633798 234.881518 97.522104 62.704111 62.875003 97.235578 146.4607 97.235578 235.361449 0 88.901773-34.530444 172.487469-97.231485 235.358379C574.112128 701.116195 490.6963 735.74897 401.976676 735.74897zM401.976676 121.204479c-75.012438 0-145.533584 29.290093-198.572568 82.474386-109.585861 109.834524-109.585861 288.539602-0.004093 398.36901 53.043077 53.188386 123.564223 82.47848 198.577684 82.47848 75.015507 0 145.553027-29.291117 198.620663-82.47848C710.126918 492.220514 710.126918 313.511343 600.593246 203.678866 547.530726 150.496619 476.992183 121.204479 401.976676 121.204479z"
              p-id="2523" fill="#FF7874">
        </path>
        <path d="M932.538427 958.228017c-6.565533 0-13.129019-2.508123-18.132986-7.52437L606.670661 642.206504c-9.989515-10.014074-9.969049-26.231431 0.045025-36.220946s26.230408-9.969049 36.220946 0.045025l307.73478 308.497143c9.989515 10.014074 9.969049 26.231431-0.045025 36.220946C945.627537 955.735244 939.081447 958.228017 932.538427 958.228017z"
              p-id="2524" fill="#FF7874">
        </path>
    </svg>
    <span class="data_count_title">查看合计</span>
    <span>订单总数:</span>
    <span class="data_count_value" id="productOrder_count_data">${requestScope.productOrderCount}</span>
    <span class="data_count_unit">个</span>
</div>
<div class="table_normal_div">
    <table class="table_normal" id="table_productOrder_list">
    <thead class="text_info">
    <tr>
        <th><input type="checkbox" class="cbx_select" id="cbx_select_all"><label for="cbx_select_all"></label></th>
        <th class="data_info" data-sort="asc" data-name="productOrder_code">
            <span>订单号</span>
            <span class="orderByDesc"></span>
            <span class="orderByAsc orderBySelect"></span>
        </th>
        <th class="data_info" data-sort="asc" data-name="productOrder_post">
            <span>邮政编码</span>
            <span class="orderByDesc"></span>
            <span class="orderByAsc orderBySelect"></span>
        </th>
        <th>收货人</th>
        <th>联系方式</th>
        <th class="data_info" data-sort="asc" data-name="productOrder_status">
            <span>订单状态</span>
            <span class="orderByDesc"></span>
            <span class="orderByAsc orderBySelect"></span>
        </th>
        <th>操作</th>
        <th hidden>订单ID</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${requestScope.productOrderList}" var="productOrder">
        <tr>
            <td><input type="checkbox" class="cbx_select" id="cbx_productOrder_select_${productOrder.productorderId}">
                <label for="cbx_productOrder_select_${productOrder.productorderId}"></label>
            </td>
            <td title="${productOrder.productorderCode}">${productOrder.productorderCode}</td>
            <td title="${productOrder.productorderPost}">${productOrder.productorderPost}</td>
            <td title="${productOrder.productorderReceiver}">${productOrder.productorderReceiver}</td>
            <td title="${productOrder.productorderMobile}">${productOrder.productorderMobile}</td>
            <td>
                <c:choose>
                    <c:when test="${productOrder.productorderStatus==0}">
                        <span class="td_await" title="等待买家付款">等待买家付款</span>
                    </c:when>
                    <c:when test="${productOrder.productorderStatus==1}">
                        <span class="td_warn" title="买家已付款，等待卖家发货">等待卖家发货</span>
                    </c:when>
                    <c:when test="${productOrder.productorderStatus==2}">
                        <span class="td_wait" title="卖家已发货，等待买家确认">等待买家确认</span>
                    </c:when>
                    <c:when test="${productOrder.productorderStatus==3}">
                        <span class="td_success" title="交易成功">交易成功</span>
                    </c:when>
                    <c:otherwise><span class="td_error" title="交易关闭">交易关闭</span></c:otherwise>
                </c:choose>
            </td>
            <td><span class="td_special" title="查看订单详情">
                <a href="javascript:void(0)" onclick="getChildPage(this)">详情</a></span>
            </td>
            <td hidden class="order_id">${productOrder.productorderId}</td>
        </tr>
    </c:forEach>
    </tbody>
    </table>
    <div class="loader"></div>

</div>
<div class="pagination">
    <ul>
        <li><a href="#" onclick="getPage(0)">«</a></li>
        <li><a href="#" onclick="getPage(${currentPage - 1})">‹</a></li>
        <li><a href="#" onclick="getPage(${currentPage})">${currentPage}</a></li>
        <li><a href="#" onclick="getPage(${currentPage + 1})">›</a></li>
        <li><a href="#" onclick="getPage(${totalPages - 1})">»</a></li>
    </ul>
</div>
</body>
</html>
